<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="Access-Control-Allow-Origin" content="*"> 
		<title>权限管理接口</title>
		<link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
		<link rel="stylesheet" href="js/themes/default/easyui.css"/>
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>
		<script src="js/lib/vue.min.js"></script>
		<script src="js/lib/vue-resource.js"></script>
		<script src="js/base.js" type="text/javascript" charset="utf-8"></script>
		<style>
		table,
		th,
		td {
			border: 1px solid grey;
			border-collapse: collapse;
			padding: 5px;
			vertical-align: middle !important;
		}		
		table td:nth-child(odd) {
			background-color: #f1f1f1;
			width:160px;
		}
		table td:nth-child(even) {
			width:160px;
		}
		table tr:nth-child(even) {
			background-color:#ffffff;
		}
		input{
			width:280px;
		}
		span{
			width:20px;color:red;display:inline-block;text-align:center;
		}
		#sho{
			width:300px;
			height:50px;
			background:#d9534f;
			opacity:0.8;
			border-radius:8px;
			color:#fff;
			text-align: center;
			font-size:30px;
			position: absolute;
			top:0px;
			left:550px;
			display:none;
		}
		</style>
	</head>
	<body>		
		<div class="" id="box">
			<div id="sho"></div>
		<!--添加权限-->
		<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
			<table class="table table-hover">				
				<tbody>
					<tr>
						<th colspan="8">添加权限:</th>
					</tr>
					<tr>
						<td/>权限标识:</td>
						<td colspan="5">
							<input id="p1" class="form-control" type="text" style="width:280px"/>
						</td>								
					</tr>
					<tr>
						<td>
							权限名称：
						</td>
						<td colspan="5">
							<input id="p2" type="text" class="form-control" style="width:280px"/>
						</td>
					</tr>
					<tr>
						<td>
							权限地址：
						</td>
						<td colspan="5">
							<input id="p3" type="text" class="form-control" style="width:280px"/>
						</td>
					</tr>
					<tr>
						<td colspan="8">
							<button v-on:click="add()" class="btn btn-danger" style="margin:0 auto">添加</button>
							<a href="查询权限.html" class="btn btn-danger" style="float:left;width:54px;display:inline-block;">
								返回
							</a>
						</td>					
					</tr>
				</tbody>
			</table>		
		</div>	
		</div>		
	</body>
	<script>
		$(function(){
	new Vue({
				el:"#box",
				data:{
					list:[],
					
				},
				methods:{
					/*添加管理权限*/
					add:function(){
						var p1 = $('#p1').val();
						var p2 = $("#p2").val();
						var p3 = $('#p3').val();
						if(p1!="" && p2!="" && p3!=""){
							this.$http.post(window.baseUrl+"user/resource/create",{
resource_no:p1,resource_name:p2,url:p3							
						},{emulateJSON:true}).then(
								   function (res) { 
								    console.log(res)
								    alert("添加成功")
								    $('#p1').val("");
						            $("#p2").val("");
						            $('#p3').val("");
								   },function (res) { 
								   	alert("添加失败")
								   	$('#p1').val("");
						            $("#p2").val("");
						            $('#p3').val("");
								   } 
								  );
						}else{
							$('#sho').show().text('信息不完整');
							$('#sho')stop().slideDown().fadeOut(2000).text('信息不完整');
						}
						
					},
					cha:function(){
						alert(1)
					},
				}
			})
			/*$.ajax({
					type:"POST",
					url:"http://192.168.1.39:80/v1.0/user/resource/query",
					dataType:"json",
					async:true,
					data:{	
					},
					success:function(data){
						console.log("开始远程调用。。。")
						console.log(data)
						if(data.resp_code==000000){
								alert("添加比率成功！")
						}
					},
					error:function(data){
						console.log("调用失败！")
					}
				})*/
			
		})
	</script>
</html>
